package com.letoken.platform.repo.app.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.letoken.platform.repo.app.po.AppFundInfo;
import com.letoken.platform.repo.app.po.AppFundLevelInfo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.web3j.abi.datatypes.Int;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 作者
 * @since 2023-08-26
 */
public interface AppFundLevelInfoMapper extends BaseMapper<AppFundLevelInfo> {
    @Select("select COUNT(DISTINCT(user_id))  from app_fund_v2_info where user_id in (select user_id from app_user_team where inviter_id = #{userId})")
   Integer getFundByInviterIdCOunt(@Param("userId") Integer userId);

    @Select("select COUNT(DISTINCT(user_id))  from app_fund_info where user_id in (select user_id from app_user_team where inviter_id = #{userId}) and fund_id>=3 and expiration_time>NOW()")
    Integer getFundByInviterIdAndTypeCOunt(@Param("userId") Integer userId);

    @Select("select COUNT(1)  from app_fund_info where user_id =#{userId} and fund_id>=3")
    Integer getFundByUserId(@Param("userId") Integer userId);

    @Select("select COUNT(1)  from app_fund_v2_info where user_id =#{userId}")
    Integer getFundByUserIdAndType(@Param("userId") Integer userId);

    @Select(" select user_id from app_fund_level_info  where `level`>0 and `level`<6;")
    List<Integer> getUserList();

    @Select(" select count(1) from app_fund_level_info  where `level`=5 and user_id= #{userId}")
    Integer getLevelBYLevl(@Param("userId")Integer userId);
    @Select(" select * from app_fund_info where create_time>='2024-01-20 00:00:00' and create_time<='2024-01-21 00:00:00' and fund_id>=3 and fund>=2000")
    List<AppFundInfo> addFundWeek();
}
